<?php
/**
 * Created by PhpStorm.
 * User: woody
 * Date: 18-10-11
 * Time: 上午10:00
 */
namespace App\Http\Controllers\Api;

use App\Models\Qrcode;
class QrcodeController extends ApiController {
    public function __construct()
    {
        parent::__construct();
        $this->_response['_active']['_model']       = 'qrcode';
        $this->_response['_active']['_action']      = '';
        $this->_response['_title']                  = '小一农货-二维码接口';
    }

//url:二维码的返回地址
   public function index(){
       global $g_uid;
       $id=$g_uid;
       $Qrcodemodel=new Qrcode();
       $data=$Qrcodemodel->scerweima('http://fitment.guoxiaoge.cn/api/wechat/login?redirect=index&inviter_id='.$id);
       $savedata=[
           'created_user'=>$id,
            'img_url'=>$data,
            'created_at'=>date('Y-m-d H:i:s',time()),
       ];
       if(!empty($data)&&$Qrcodemodel->saveData($savedata)){
           $this->_response['personinfo'] = $data;
           return response()->json(['code' => 0, 'msg' => '返回成功','data'=>$this->_response]);
       }else{
           return response()->json(['code' => -1, 'msg' => '返回失败']);
       }
   }

}

